﻿using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TheGame
{
    //Gestisce il sondaggio proposto al giocatore a fine percorso
    //[p.76,77]
    public class Report
    {
        Game1 game;
        public Texture2D BackGround;
        public List<Level> LEVELS;
        public int LVL_INDEX = 0;

        public Rectangle DrawRecLvl;

        public bool FDown = true;
        public bool FUp = true;
        public bool FOne = true;
        public bool FTwo = true;

        public SoundEffect UPDOWN;
        public SoundEffect OK;
        public SoundEffect NO;


        public Report(Game1 game)
        {
            this.game = game;
            LEVELS = new List<Level>();
            BackGround = game.Content.Load<Texture2D>("REPORT\\Background");

            DrawRecLvl = new Rectangle(200, 150, 240, 180);

            UPDOWN = game.Content.Load<SoundEffect>("Sound\\PORTALENTER");
            OK = game.Content.Load<SoundEffect>("Sound\\OK");
            NO = game.Content.Load<SoundEffect>("Sound\\NO");
        }

        public void Control()
        {
            if (game.downDown & FDown & LVL_INDEX < LEVELS.Count - 1)
            {
                FDown = false;
                UPDOWN.Play(0.1f);
                LVL_INDEX++;
            }
            if (!game.downDown)
                FDown = true;

            if (game.upDown & FUp & LVL_INDEX > 0)
            {
                FUp = false;
                UPDOWN.Play(0.1f);
                LVL_INDEX--;
            }
            if (!game.upDown)
                FUp = true;

            if (game.OneDown & FOne)//Giudizio positivo(livello superato con facilità)
            {
                FOne = false;
                OK.Play(0.1f);
                Level lvlMod = LevelMaker.getLevelByName(LEVELS[LVL_INDEX].NAME);
                lvlMod.Modify("DIFF_UP");
                lvlMod.SetDifficult();
                LEVELS.Remove(LEVELS[LVL_INDEX]);
                LVL_INDEX = 0;
                if (LEVELS.Count == 0)
                {
                    game.ReInit();
                    game.SHOW_REPORT = false;
                    game.NUMLVLGEN = 0;
                }
            }
            if (!game.OneDown)
                FOne = true;

            if (game.TwoDown & FTwo)///Giudizio negativo(livello superato con difficoltà)
            {
                FTwo = false;
                NO.Play(0.1f);
                Level lvlMod = LevelMaker.getLevelByName(LEVELS[LVL_INDEX].NAME);
                lvlMod.Modify("DIFF_DOWN");
                lvlMod.SetDifficult();

                LEVELS.Remove(LEVELS[LVL_INDEX]);
                LVL_INDEX = 0;
                if (LEVELS.Count == 0)
                {
                    game.ReInit();
                    game.SHOW_REPORT = false;
                    game.NUMLVLGEN = 0;
                }
            }
            if (!game.TwoDown)
                FTwo = true;
        }
    }
}
